home *** CD-ROM | disk | FTP | other *** search
- code segment
- assume cs:code,ds:code
- org 100h
-
-
- ;exec written by alan vanchura
- ;
- ;friendlysoft inc
- ;3638 west pioneer pkwy
- ;arlington tx 76013
-
- ;817 496 8151 (home)
-
- ;this program will save current drive and directory
- ;then will switch to drive and pathname
- ;then exec the filename.ext (under 3.0 a pathname may be added to filename.ext
- ;when finished it will return to orginal drive and pathname
- ;
- ;command.com must be accessable by exec through set comspec=c:\command.com
- ;Also if filename.ext is not in the current directory, then drive:pathname\
- ;must be added
- ;
- ;SYNTAX:
- ; exec d:\pathname filename.ext [optional parms]
- ;
- ;EXAMPLES:
- ; exec c:\qmodem qmodem.com
- ;
- ; exec c:\dos format.com a:/s/1
- ;
- ; exec c:\games\sub1 c:\dos\basica.com menu.bas
- ;
-
- start proc
- jmp begin
-
- db 13,"written by Alan Vanchura, FriendlySoft,Inc.",13,10
- db "version 2.0 04/14/85",13,10
- db "version 2.1 05/16/85",13,10,1ah
-
- drive$ db 0 ;current drive
- path$ db 66 dup(0) ;current pathname
- pathc$ db 80 dup(0) ;drive and path to switch to
- namec$ db 40 dup(0) ;pathname\filename to exec
- command$ db 40 dup(0) ;optional parms following filename
-
- error1$ db "Memory shrink error$"
-
- error3$ db "Exec failure.$"
- error4$ db "written by Alan Vanchura, FriendlySoft,Inc.",13,10
- db "version 2.0 04/14/85",13,10
- db "version 2.1 05/16/85",13,10
- db "Command line syntax is ",13,10
- db "exec d:\pathname d:\path\filename.ext [optional parms]$"
-
- error5$ db "drive must be specified before pathname$"
- error6$ db "invalid drive specified$"
- error7$ db "invalid path specified$"
-
- sp_save dw 0
-
- parm_block label word
- environment_seg dw 0
- command_line dd 0
- default_fcb1 dd 0
- default_fcb2 dd 0
-
- begin:
- mov ah,19h
- int 21h
- mov dl,al
- mov drive$,dl ;drive
-
- mov ah,47h ;get directory
- lea si,path$
- inc dl ;current drive
- int 21h
-
- lea bx,new_dta ;set size of needed code
- shr bx,1
- shr bx,1
- shr bx,1
- shr bx,1
- inc bx
- mov ah,4ah
- int 21h ;shrink memory
- jnc rt110
- lea dx,error1$
- jmp exit
- rt110:
- cld
- mov si,offset 80h
- lodsb
- and al,al ;any thing on command line?
- jnz rt120 ;yes
- lea dx,error4$ ;else show command syntax
- jmp exit
- rt120:
- lodsb ;space
- lodsb ;get drive letter
- and al,0ffh-20h ;force to uppercase
- sub al,"A" ;adjust for set drive call
- mov ah,0eh
- mov dl,al
- int 21h ;set drive
- cmp al,dl ;drive set?
- ja rt140 ;yes
- lea dx,error6$ ;drive letter invalid
- jmp exit
- rt140:
- lodsb ;make sure
- cmp al,":" ;valid drive and colon
- je rt150
- lea dx,error5$ ;drive must be specified
- jmp exit
- rt150:
- lea di,pathc$ ;
- rt151:
- lodsb ;move pathname to save area
- cmp al," "
- je rt160
- stosb
- jmp rt151
- rt160:
- xor al,al ;end it with zero
- stosb
- lea di,namec$
- rt161:
- lodsb ;move filename to save area
- cmp al," "
- je rt170
- cmp al,0dh
- je rt170
- stosb
- jmp rt161
- rt170:
- mov word ptr command_line,si ;save for check for parameters
- xor al,al
- stosb
-
- lea dx,pathc$ ;set path
- mov ah,3bh
- int 21h
- jnc rt180 ;no error
- lea dx,error7$ ;invalid path
- jmp exit
- rt180:
- mov sp_save,sp ;save stack pointer
-
- lea di,command$+1 ;command line save area
- mov si,word ptr command_line
- cmp byte ptr [si-1],0dh ;any parms?
- je rt189 ;no
- mov cx,39 ;length of parm save area
- rt181:
- lodsb ;move parms to save area
- stosb
- cmp al,0dh ;of command line
- je rt189
- inc byte ptr command$ ;adjust counter at start
- loop rt181
- rt189:
- mov ax,word ptr ds:[002ch] ;setup paramater block
- mov environment_seg,ax ;for exec function
- mov word ptr command_line,offset command$
- mov word ptr command_line+2,ds
- mov word ptr default_fcb1,5ch
- mov word ptr default_fcb1+2,ds
- mov word ptr default_fcb2,6ch
- mov word ptr default_fcb2+2,ds
-
- lea si,command$+1 ;parse any parms
- mov di,word ptr default_fcb1 ;to fcb at 5ch
- mov ah,29h ;for pass to program being
- mov al,0 ;invoked
- int 21h
-
- lea dx,namec$ ;exec filename.ext
- lea bx,parm_block
- mov ah,4bh
- mov al,00h
- int 21h
-
- cli
- mov ax,cs ;restore seg registers
- mov ds,ax
- mov es,ax
- mov ss,ax
- mov sp,sp_save
- sti
-
- lea dx,error3$ ;any errors
- jc exit ;yes. exec not successful
-
- mov dl,drive$ ;restore to orginal drive
- mov ah,0eh
- int 21h
-
- lea dx,path$ ;restore to orginal path
- cmp byte ptr path$,'\'
- je rt190
- dec dx
- mov byte ptr path$-1,'\'
- rt190:
- mov ah,3bh
- int 21h
- int 20h ;finished
- exit:
- mov ah,9
- int 21h
- int 20h
-
- start endp
-
- new_dta dw 0
-
- code ends
- end start